package falstad;

import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFileChooser;
import javax.swing.JMenu;



public class MenuActionListener implements ActionListener{
	Container parent ;
	Maze maze ;
	JMenu menu;
	JFileChooser fc = new JFileChooser();

	MenuActionListener(Container parent, Maze maze, JFileChooser fc){
		this.parent = parent ;
		this.maze = maze ;
		this.fc = fc;
	}
	
	@Override
	public void actionPerformed(ActionEvent arg0) {
		String selection =  arg0.getActionCommand();
		System.out.println(selection);
		switch(selection)
		{
		case Constants.MENU_FILE_OPEN:
		{
			fc.showOpenDialog(parent);
//			this.maze = new Maze(fc.getSelectedFile().getPath());
			MazeApplication temp = new MazeApplication(fc.getSelectedFile().getPath());
			break;
		}
		case Constants.MENU_FILE_SAVE:
		{
			fc.showSaveDialog(parent);
			MazeFileWriter temp =  new MazeFileWriter();
			temp.storeWorkingMaze(maze, fc.getSelectedFile().getName());
		}
		}
	}
	

}

